package server;
import com.hankcs.hanlp.tokenizer.NLPTokenizer;
import com.hankcs.lucene.HanLPTokenizer;
import org.ansj.lucene.util.AnsjTokenizer;
import org.ansj.recognition.impl.StopRecognition;
import org.ansj.recognition.impl.SynonymsRecgnition;
import org.ansj.splitWord.Analysis;
import org.ansj.splitWord.analysis.NlpAnalysis;
import org.apache.lucene.analysis.Analyzer;

import java.util.List;
import java.util.Set;

/**
 * Created by xjz on 2017/10/11.
 */

public class ANSJBinaryAnalyzer extends Analyzer{

    private List<StopRecognition> stops;
    List<SynonymsRecgnition> synonyms;
    Analysis analysis;

    public ANSJBinaryAnalyzer(List<StopRecognition> stops, List<SynonymsRecgnition> synonyms) {
        this.stops = stops;
        this.synonyms = synonyms;
    }

    public ANSJBinaryAnalyzer() {
    }

    public ANSJBinaryAnalyzer(Analysis analysis) {
        this.analysis = analysis;
    }

    protected TokenStreamComponents createComponents(String fieldName) {
        AnsjTokenizer tokenizer = new AnsjTokenizer(analysis, this.stops, this.synonyms);
        //TokenStream tokenStream = new ShingleFilter(tokenizer);
        return new TokenStreamComponents(tokenizer, tokenizer);
    }

}
